<?php
/**
 * Created by PhpStorm.
 * User: liuxiu
 * Date: 2022/2/28
 * Time: 17:37
 */

namespace search\controllers\marketDataAnalysis;


use business\elasticsearch\services\SubBiddingService;

class SubsBiddingController extends BaseController
{
    /**
     * @api {get} /marketDataAnalysis/subs-bidding/list 01、搜索招标订阅数据
     *
     * @apiVersion 1.0.0
     * @apiGroup marketDataAnalysis
     *
     * @apiDescription 搜索招标订阅数据
     *
     * @apiParam {String} keyword                   搜索词
     * @apiParam {String} province_code             省份code
     * @apiParam {String} stage                     公告类型, 1.招标公告 2.中标公告
     * @apiParam {String} source_type               来源类型 1.开发商官网
     * @apiParam {String} release_time_start        发布时间--起始时间
     * @apiParam {String} release_time_start_end    发布时间--结束时间
     * @apiParam {String} page                      页码
     * @apiParam {String} pageSize                  分页size
     * @apiParam {String} release_time_sort         release_time 0 升序 1 降序
     *
     *
     * @apiSuccessExample {json} 成功响应：
     * {"success":true,"message":null,"errorCode":null,"data":{"resultSet":[{"uid":19,"title":"庐江县全域旅游大数据中心建设项目公开招标公告",
     * "intro":"庐江县全域旅游大数据中心建设项目公开招标公告（网上招投标）,,安徽诚信项目管理有限公司受智慧时代（庐江）投资管理有限公司、庐江县旅游局的委托，现对“庐江县全域旅游大数据中心建设项目”进行公开招标，欢迎","province_code":"111","province_name":"安徽","source_type":0,"release_time":"2019-07-16 11:30:27",
     * "stage":1,"indexCreatedTime":"2022-03-01 07:12:01","titleHL":"庐江县全域<em class=\"_high\">旅游</em>大数据中心建设项目公开招标公告"}],
     * "resultNum":1}}
     *
     */
    public function actionList()
    {
        try{
            $params = array();
            $params['keyword'] = $this->getParam('keyword');
            $params['province_code'] = $this->getParam('province_code');
            $params['page'] = $this->getParam('page');
            $params['pageSize'] = $this->getParam('pageSize');
            $params['release_time_sort'] = $this->getParam('release_time_sort');
            $params['stage'] = $this->getParam('stage');
            $params['source_type'] = $this->getParam('source_type');
            $params['release_time_start'] = $this->getParam('release_time_start');
            $params['release_time_start_end'] = $this->getParam('release_time_start_end');

            $params['page'] = !empty($params['page']) ? intval($params['page']) : 1;
            $params['pageSize'] = !empty($params['pageSize']) ? intval($params['pageSize']) : 10;

            $subBiddingService = new SubBiddingService();
            $rs = $subBiddingService->getList($params);
            return $this->success($rs);
        } catch (\Exception $ex){
            \Yii::error($ex->getMessage());
            return $this->error('', '获取失败，请稍后重试');
        }
    }

}